package org.bing.engine.console.service;

import org.bing.engine.common.remoting.RemotingInvoker;
import org.bing.engine.console.remote.RemoteFactory;
import org.bing.engine.core.domain.BalancerInstance;
import org.bing.engine.core.domain.BalancerSetting;
import org.bing.engine.core.domain.Controller;

public class BalancerInstanceManager extends AbstractHibernateManager {
    private static final String serviceId = "controller.GeneralBalancerLifecycle";
    private RemoteFactory remoteFactory;

    public void setRemoteFactory(RemoteFactory factory) {
        this.remoteFactory = factory;
    }

    public BalancerInstance startNew(Controller controller, BalancerSetting setting) {
        RemotingInvoker invoker = remoteFactory.getRemoteInvoker(controller, serviceId);
        return (BalancerInstance) invoker.invoke("startNew", new Object[] { setting });
    }
}
